#include <sourcemod>

#define PLUGIN_VERSION "1.0.1"

#define ZOMBIECLASS_SMOKER	1
#define ZOMBIECLASS_BOOMER	2
#define ZOMBIECLASS_HUNTER	3
#define ZOMBIECLASS_TANK	5
public Plugin:myinfo = 
{
	name = "Show remain Health",
	author = "xiaohai",
	description = "Shows emeny health on the screen",
	version = PLUGIN_VERSION,
	url = "www.sourcemod.net"
}

 
 

public OnPluginStart()
{
	CreateConVar("sm_show_health_version", PLUGIN_VERSION, "Show Health Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
 	
	HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
	//HookEvent("infected_hurt", infected_hurt, EventHookMode_Post);
   
	AutoExecConfig(true, "l4d_showhealth");
 }
public Action:infected_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
	new  attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	 
	new  type = GetEventInt(event, "type");

	/*new String:weapon[100];
	 GetEventString(event, "weapon", weapon, sizeof(weapon));*/
	if(attacker > 0 && IsClientInGame(attacker) && !IsFakeClient(attacker))
	{
		PrintToChatAll("hurt type %d", type);
	}
}

public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
	new  attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new  victim = GetClientOfUserId(GetEventInt(event, "userid"));
	new  remainhealth = GetEventInt(event, "health");
	new  dmg = GetEventInt(event, "dmg_health");
	new  type = GetEventInt(event, "type");

	/*new String:weapon[100];
	 GetEventString(event, "weapon", weapon, sizeof(weapon));*/
	if(attacker > 0 && IsClientInGame(attacker) && !IsFakeClient(attacker))
	{
		//PrintToChatAll("hurt type %d", type);
		if(victim>0 && IsClientInGame(victim) )
		{
			if(GetClientTeam(victim)==3)
			{
				//new class = GetEntProp(victim, Prop_Send, "m_zombieClass");
 
 			//	if(class == ZOMBIECLASS_TANK)
				//{
				//	if(remainhealth>6000)
				//	{
				//		PrintCenterText(attacker, "%d  /  %d %N", dmg, remainhealth, victim);	
				//	}
				//	else
				//	{
				//		PrintCenterText(attacker, "%d %N", dmg, victim);	
				//	}
 			//	}
				//else 
				{
					PrintCenterText(attacker, "%d  /  %d %N", dmg, remainhealth, victim);	
				}
			}
			else if(GetClientTeam(victim)==2)
			{
 				PrintCenterText(attacker, "%d  /  %d %N", dmg, remainhealth, victim);	
			}
			else 
			{
				PrintCenterText(attacker, "%d / %d", dmg, remainhealth);	
			}

		}
		else 
		{
			PrintCenterText(attacker, "%d / %d", dmg, remainhealth);	
		}
	}
	if(victim>0 && IsClientInGame(victim) && !IsFakeClient(victim))
	{
		if(attacker>0 && IsClientInGame(attacker))
		{
 		 	PrintCenterText(victim, "%N 伤害了你 %d", attacker, dmg);	
		}
		else 
		{
 	 		PrintCenterText(victim, "受到伤害 %d",  dmg);	
		}
	}
 	 
  
	return Plugin_Continue;
}
 

 